	PRO COMCAMPOS,scalar,vecx,vecy,x,y
; Compute a field components 'vecx' and 'vecy' from scalar potential 'scalar'
N=(size(scalar))(1)
dx=x(1)
vecx=dblarr(N,N)
vecy=vecx
; Compute field component vecx = d scalar / dy
vecx(*,1:N-2)=(scalar(*,2:N-1)-scalar(*,0:N-3))/(2.*dx)
vecx(*,0)=(scalar(*,1)-scalar(*,N-1))/(2.*dx)
vecx(*,N-1)=(scalar(*,0)-scalar(*,N-2))/(2.*dx)
; Compute field component vecy = -d scalar / dx
vecy(1:N-2,*)=-(scalar(2:N-1,*)-scalar(0:N-3,*))/(2.*dx)
vecy(0,*)=-(scalar(1,*)-scalar(N-1,*))/(2.*dx)
vecy(N-1,*)=-(scalar(0,*)-scalar(N-2,*))/(2.*dx)
end
